#ifndef CMANAGEEX_H
#define CMANAGEEX_H

#include "stdafx.h"
#include "CRectangleEx.h"
#include "CCircleEx.h"
#include "CTriangleEX.h"
#include "CShapeEx.h"
#include "ShapeAttribute.h"
#include "CLineEx.h"
#include "CRoundRectangleEx.h"
#include "CTextEx.h"

class CManageEx
{
	private:
		int quantity;
		POINT point1;
		POINT point2;
		POINT oldPoint2;
		bool allowMoving; // TRUE when select correct shape(s)
		bool isMoving; 
		bool isSeleting; // che do select
		bool isDrawing;
		bool allowTyping;
		bool isTyping;
		bool isResizing;
		bool allowResizing;
		int position;
		int selectingQuantity;
		int maxtop; // top of highest shape
		int minbottom;// bottom of lowest shape
		int minleft;
		int maxright;
		int numbertextshape;
		char buffer[BUFSIZ];
		TextAttribute* tAttribute;

	public:
		vector <CShapeEx*> listShape;
		vector <int> selectingPosition;
		CRectangleEx selectRect;
		vector <char[BUFSIZ]> textshape;

	public:
		CManageEx();
		void InsertShape(CRectangleEx rect, int index);
		void InsertShape(CCircleEX cir, int index);
		void InsertShape(CTriangleEx tri, int index);
		void InsertShape(CLineEx line, int index);
		void InsertShape(CRoundRectangleEx roundrect, int index);
		void InsertShape(CTextEx text, int index);
		void DeleteShape(int index);
		void DeleteShape();
		void AddSelectedShape(int index);
		void ResetSelectedShape();
		CShapeEx* GetShape(int index);
		void ShowAll(HDC);
		bool CheckInShape(POINT);
		void CheckInShape(POINT, POINT);
		void DrawSelected(HDC);
		void DrawSelecting(HDC);
		void Move(int, int);
		void SelectShape(HDC, HWND, UINT, WPARAM, LPARAM);
		void DrawShape(HDC, HWND, UINT, WPARAM, LPARAM, ShapeAttribute);
		void DrawTextShape(HDC, HWND, UINT, WPARAM, LPARAM, ShapeAttribute);
		void CreateNewGraphic();
		bool SaveGraphic(HWND, TCHAR*);
		bool OpenGraphic(HWND hWnd, TCHAR* address);
		int CheckResizingMode(POINT);
		void Resize(int, int, int);
		void CurMaxMin();

};

#endif